home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / stk-3.002 / stk-3 / STk-3.1 / Demos / Widget / Wstyles.stklos < prev    next >
Encoding:
Text File  |  1995-08-23  |  6.0 KB  |  165 lines

  1. ;;;;
  2. ;;;; STk adaptation of the Tk widget demo.
  3. ;;;;
  4. ;;;; This demonstration script creates a text widget that illustrates the
  5. ;;;; various display styles that may be set for tags.
  6. ;;;;
  7. (require "Tk-classes")
  8.  
  9. (define (demo-styles)
  10.   (let* ((w          (make-demo-toplevel "styles"
  11.                      "Text Demonstration - Display Styles"
  12.                      ""))
  13.      (t          (make <Scroll-Text> :parent w :setgrid #t :width 70 
  14.                :height 23 :wrap "word"))
  15.      (bold       (make <Text-tag> :parent t 
  16.                :font "-*-Courier-Bold-O-Normal--*-120-*-*-*-*-*-*"))
  17.      (big        (make <Text-tag> :parent t
  18.                :font "-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*"))
  19.      (huge       (make <Text-tag> :parent t
  20.                :font "-*-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*"))
  21.      (color1     (make <Text-tag> :parent t
  22.                :background "#a0b7ce"))
  23.      (color2     (make <Text-tag> :parent t
  24.                :foreground "red"))
  25.      (raised     (make <Text-tag> :parent t
  26.                :relief "raised" :border-width 1))               
  27.      (sunken     (make <Text-tag> :parent t
  28.                :relief "sunken" :border-width 1))
  29.      (bgstipple  (make <Text-tag> :parent t
  30.                :background "black" :border-width 0 
  31.                :bg-stipple "gray25"))
  32.      (fgstipple  (make <Text-tag> :parent t
  33.                :fg-stipple "gray50"))
  34.      (underline  (make <Text-tag> :parent t
  35.                :underline #t))
  36.      (overstrike (make <Text-tag> :parent t
  37.                :overstrike #t))
  38.      (right      (make <Text-tag> :parent t
  39.                :justify "right"))
  40.      (center     (make <Text-tag> :parent t
  41.                :justify "center"))
  42.      (super      (make <Text-tag> :parent t
  43.                :font "-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*"
  44.                :offset 4))
  45.      (sub          (make <Text-tag> :parent t
  46.                :font "-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*"
  47.                :offset -2))
  48.      (margins    (make <Text-tag> :parent t
  49.                :lmargin1 "12m" 
  50.                :lmargin2 "6m"
  51.                :rmargin  "10m"))
  52.      (spacing    (make <Text-tag> :parent t
  53.                :spacing1 "10p" 
  54.                :spacing2 "2p"
  55.                :lmargin1 "12m"
  56.                :lmargin2 "6m" 
  57.                :rmargin "10m")))
  58.  
  59.     (when (= (winfo 'depth w) 1)
  60.         ;; Monochrome
  61.     (slot-set! color1 :background   "black")
  62.     (slot-set! color1 :foreground   "white")
  63.     (slot-set! color2 :background   "black")
  64.     (slot-set! color2 :foreground   "white")
  65.     (slot-set! raised :background   "white")
  66.     (slot-set! raised :relief       "raised")
  67.     (slot-set! raised :border-width 1)
  68.     (slot-set! sunken :background   "white")
  69.     (slot-set! sunken :relief       "sunken")
  70.     (slot-set! sunken :border-width 1))
  71.  
  72.     (pack t :expand #t :fill "both")
  73.  
  74.     (text-insert t "end" 
  75. "Text widgets like this one allow you to display information in a
  76. variety of styles.  Display styles are controlled using a mechanism
  77. called "                        '()
  78. "tags"                             bold
  79. ". Tags are just textual names that you can apply to one
  80. or more ranges of characters within a text widget.  You can configure
  81. tags with various display styles.  If you do this, then the tagged
  82. characters will be displayed with the styles you chose.  The
  83. available display styles are:"                 '()
  84. "\n1. Font."                         big
  85. "  You can choose any X font, "             '()
  86. "large"                         huge
  87. " or "                          '()
  88. "small.\n"                         '()
  89. "\n2. Color."                         big
  90. "  You can change either the "                 '()
  91. "background"                         color1
  92. " or "                            '()
  93. "foreground"                         color2
  94. "\ncolor, or "                        '()
  95. "both"                             (list color1 color2)
  96. ".\n"                            '()
  97. "\n3. Stippling."                     big
  98. "  You can cause either the "                '()
  99. "background"                         bgstipple
  100. " or "                            '()
  101. "foreground "                         fgstipple
  102. "information to be drawn with a stipple fill instead of a solid fill."
  103.                             '()
  104. "\n4. Underlining."                     big
  105. "  You can "                        '()
  106. "underline"                         underline
  107. " ranges of text.\n"                    '()
  108. "\n5. Overstrikes."                     big
  109. "  You can "                        '()
  110. "draw lines through"                     overstrike
  111. " ranges of text.\n"                    '()
  112. "\n6. 3-D effects."                     big
  113. "  You can arrange for the background to be drawn
  114. with a border that makes characters appear either "    '()
  115. "raised"                         raised
  116. " or "                            '()
  117. "sunken"                         sunken
  118. ".\n"                            '()
  119. "\n7. Justification."                     big
  120. " You can arrange for lines to be displayed
  121. left-justified,\n"                    '()
  122. "right-justified, or\n"                    right
  123. "centered.\n"                         center
  124. "\n8. Superscripts and subscripts."              big
  125. " You can control the vertical position of text \
  126. to generate superscript effects like 10"        '()
  127. "n"                             super
  128. " or\nsubscript effects like X"                '()
  129. "i"                             sub
  130. ".\n"                            '()
  131. "\n9. Margins."                     big
  132. " You can control the amount of extra space left"    '()
  133. " on\neach side of the text:\n"                '()
  134. "This paragraph is an example of the use of "         margins
  135. "margins.  It consists of a single line of text "    margins
  136. "that wraps around on the screen.  There are two "    margins
  137. "separate left margin values, one for the first "    margins
  138. "display line associated with the text line, "        margins
  139. "and one for the subsequent display lines, which "    margins
  140. "occur because of wrapping.  There is also a "        margins
  141. "separate specification for the right margin, "        margins
  142. "which is used to choose wrap points for lines.\n"    margins
  143. "\n10. Spacing."                     big
  144. " You can control the spacing of lines with three\n"    '()
  145. "separate parameters.  \"Spacing1\" tells how much "    '()
  146. "extra space to leave\nabove a line, \"spacing3\" "    '()
  147. "tells how much space to leave below a line,\nand "    '()
  148. "if a text line wraps, \"spacing2\" tells how much "    '()
  149. "space to leave\nbetween the display lines that "    '()
  150. "make up the text line.\n"                '()
  151. "These indented paragraphs illustrate how spacing "     spacing
  152. "can be used.  Each paragraph is actually a "         spacing
  153. "single line in the text widget, which is "         spacing
  154. "word-wrapped by the widget.\n"             spacing
  155. "Spacing1 is set to 10 points for this text, "         spacing
  156. "which results in relatively large gaps between "     spacing
  157. "the paragraphs.  Spacing2 is set to 2 points, "     spacing
  158. "which results in just a bit of extra space "         spacing
  159. "within a pararaph.  Spacing3 isn't used "         spacing
  160. "in this example.\n"                     spacing
  161. "To see where the space is, select ranges of "         spacing
  162. "text within these paragraphs.  The selection "     spacing
  163. "highlight will cover the extra space."         spacing
  164. )))
  165.